/**
 * 
 */
package com.huarui.desktop;

import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.ewaf.framework.action.BaseAction;
import org.ewaf.framework.model.PagingInfo;

import com.huarui.desktop.model.TableMetaData;
import com.huarui.desktop.service.TableMetaDataService;
import com.huarui.desktop.service.TableRecordDataService;
import com.opensymphony.xwork2.Action;

/**
 * @author sunpeng
 * 
 */
public class ModuleDataAction extends BaseAction {

	private static final long serialVersionUID = 6790827419279938606L;
	private int start=0;
	private int limit=20;
	private String tableName;
	private TableMetaDataService tableMetaDataService;
	private TableRecordDataService tableRecordDataService;

	public String paging() {
		TableMetaData metaData = this.tableMetaDataService.viewTableMetaData(this.tableName);
		PagingInfo<String, Map<String, Object>> paginInfo = new PagingInfo<String, Map<String, Object>>();
		paginInfo.setStart(this.start);
		paginInfo.setLimit(this.limit);
		this.tableRecordDataService.list(metaData, paginInfo);
		ServletActionContext.getContext().put("jsonResult", paginInfo);
		return Action.SUCCESS;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public void setTableMetaDataService(TableMetaDataService tableMetaDataService) {
		this.tableMetaDataService = tableMetaDataService;
	}

	public void setTableRecordDataService(TableRecordDataService tableRecordDataService) {
		this.tableRecordDataService = tableRecordDataService;
	}

}
